﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using D3crft.Windows.UserControls;
using System.Globalization;

namespace D3crft.Windows {


    public static class scGUIFunctions {

        public static bool correct_INTucTextBox(ucTextBox oTextBox) {
            int iTemp;
            string sText = oTextBox.Text;

            if (sText.Length != 0) {
                if (!int.TryParse(sText, out iTemp)) {
                    oTextBox.RevertLastText();
                    return false;
                }
            }
            else {
                oTextBox.Text = "0";
                oTextBox.TextBox.SelectAll();
            }
            return true;
        }

        public static bool correct_FLOATucTextBox(ucTextBox oTextBox) {
            float fTemp;
            string sText = oTextBox.Text;

            if (sText.Length != 0) {
                if (!float.TryParse(sText, NumberStyles.Float, CultureInfo.InvariantCulture, out fTemp)) {
                    oTextBox.RevertLastText();
                    return false;
                }
            }
            else {
                oTextBox.Text = "0.0";
                oTextBox.TextBox.SelectAll();
            }
            return true;
        }

    }
}
